package com.yuxi.excelEntity;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yuxi.Config.PortStaticUtil;
import com.yuxi.Entity.UserTaskCompletion;
import com.yuxi.Util.StringManageUtil;

public class OwnWordInfo {
	private Integer infocontenId;//
	private String portName;
	private String portId;
	private String infoaccount="";//
	private String infoconten="";//信息内容	
	private String persons="";
	private String stanand="";//标准
	private String metrue="" ;	//措施
	private String time="";//任务完成情况	
	private String task="" ;
	private String tasktime="" ;	
	private String taskNames="";
	private String comment="";
	
	
	public String getPortId() {
		return portId;
	}

	public void setPortId(String portId) {
		this.portId = portId;
	}

	public String getPortName() {
		return portName;
	}

	public void setPortName(String portName) {
		this.portName = portName;
	}

	public String getMetrue() {
		return metrue;
	}

	public void setMetrue(String metrue) {
		this.metrue = metrue;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public Integer getInfocontenId() {
		return infocontenId;
	}

	public void setInfocontenId(Integer infocontenId) {
		this.infocontenId = infocontenId;
	}

	public String getInfoaccount() {
		return infoaccount;
	}

	public void setInfoaccount(String infoaccount) {
		this.infoaccount = infoaccount;
	}

	public OwnWordInfo(Object infoconten, Object persons,Object mesure, Object time, Object task,
			Object taskNames,Object infoLV,Object luLv,Object portNames,Object portId) {
		super();
		String	infocontenN=" ";
		if(infoconten!=null){
			infocontenN=infoconten.toString().replaceAll("<br>", "").replaceAll("&nbsp;", " ");
		}
		this.portId=portId.toString().replaceAll("<br>", "").replaceAll("&nbsp;", " ");
		String	personsN=" ";
		if(persons!=null){
			personsN=persons.toString().replaceAll("<br>", "").replaceAll("&nbsp;", " ");
		}	
		String	mesureN=" ";
		if(mesure!=null){
			mesureN=mesure.toString().replaceAll("<br>", "").replaceAll("&nbsp;", " ");
		}	
		String	timeN=" ";
		if(time!=null){
			timeN=time.toString().replaceAll("<br>", "").replaceAll("&nbsp;", " ");
		}
		String	taskN=" ";
		if(task!=null){
			taskN=task.toString().replaceAll("<br>", "").replaceAll("&nbsp;", " ");
		}
		String	taskNamesN=" ";
		if(taskNames!=null){
			taskNamesN=taskNames.toString().replaceAll("<br>", "").replaceAll("&nbsp;", " ");
		}	
		this.portName=portNames.toString().replaceAll("<br>", "").replaceAll("&nbsp;", " ");	
		this.infoconten = infocontenN;
		this.persons = personsN;		
		this.metrue = mesureN;
		String dat="";
		try{
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			dat = sdf.format(new Date(Long.parseLong(timeN)));
		}catch(Exception e){
			dat=timeN;
		}
		this.time = dat;
		this.task = "";
		this.tasktime = "";
		this.comment="信息录入和收集质量："+(infoLV==null?"待评价":infoLV.toString())+" 任务完成情况："+(luLv==null?"待评价":luLv.toString());
		List<UserTaskCompletion> list=new Gson().fromJson(taskN, new TypeToken<List<UserTaskCompletion>>(){}.getType());
		if(list!=null){
			for(int i=0;i<list.size();i++){
				UserTaskCompletion u=list.get(i);
				SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
				String dat1 = sdf1.format(new Date(Long.parseLong(u.getTime())));				
				this.task+=u.getName()+":"+u.getText();
				this.tasktime+=u.getName()+":"+dat1;
			}	
		}	
		
	
		this.taskNames = StringManageUtil.removeDot(taskNamesN);
		this.portName=PortStaticUtil.getAllpreStr(Integer.parseInt(this.portId));
	}
	
	public OwnWordInfo(Integer infoId,String infoAcc,String infoconten, String persons, String mesure, String time, String task,
			 String taskNames,String infoLV,String luLv) {
		
		super();
		this.infocontenId=infoId;
		this.infoaccount=infoAcc;
		this.infoconten = infoconten;
		this.persons = persons;		
		this.metrue = mesure;
		this.time = time;
		this.task = "";
		this.tasktime = "";
		this.comment="信息录入和收集质量："+infoLV+" 任务完成情况："+luLv;
		List<UserTaskCompletion> list=new Gson().fromJson(task, new TypeToken<List<UserTaskCompletion>>(){}.getType());
		if(list!=null){
			for(int i=0;i<list.size();i++){
				UserTaskCompletion u=list.get(i);
				SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
				String dat1 = sdf1.format(new Date(Long.parseLong(u.getTime())));				
				this.task+=u.getName()+":"+u.getText();
				this.tasktime+=u.getName()+":"+dat1;
			}	
		}	
		
	
		this.taskNames = taskNames;
	}
	public String getInfoconten() {
		return infoconten;
	}
	public void setInfoconten(String infoconten) {
		this.infoconten = infoconten;
	}
	public String getPersons() {
		return persons;
	}
	public void setPersons(String persons) {
		this.persons = persons;
	}
	public String getStanand() {
		return stanand;
	}
	public void setStanand(String stanand) {
		this.stanand = stanand;
	}
	
	public String getTime() {
		return time;
	}
	public void setTime(String time) {
		this.time = time;
	}
	public String getTask() {
		return task;
	}
	public void setTask(String task) {
		this.task = task;
	}
	public String getTasktime() {
		return tasktime;
	}
	public void setTasktime(String tasktime) {
		this.tasktime = tasktime;
	}
	public String getTaskNames() {
		return taskNames;
	}
	public void setTaskNames(String taskNames) {
		this.taskNames = taskNames;
	}
	public OwnWordInfo() {
		super();
	}

	@Override
	public String toString() {
		return "OwnWordInfo [infocontenId=" + infocontenId + ", portName=" + portName + ", portId=" + portId
				+ ", infoaccount=" + infoaccount + ", infoconten=" + infoconten + ", persons=" + persons + ", stanand="
				+ stanand + ", metrue=" + metrue + ", time=" + time + ", task=" + task + ", tasktime=" + tasktime
				+ ", taskNames=" + taskNames + ", comment=" + comment + "]";
	}

	
	
	
}
